
var netUtil = require('/../../utils/netUtil.js')
var util = require('/../../utils/util.js')
var app = getApp();

Page({
  data:{
 		getOrderDetail : null,
 		voucherId : null
  },
  onLoad:function(options){
  	
  	//提查单订单号
	 	var voucherId = options.voucherId;
  	if(voucherId != undefined && voucherId != null) {
  		this.setData({
  			voucherId : voucherId
  		});
  	}
  	
  	app.getUserOpedId(this.queryGetOrderDetailArray);
  },
  onReady:function(){
  
  },
  onShow:function(){
    
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },

  onUnload:function(){
    // 页面关闭

  },
  
  queryGetOrderDetailArray : function() {
  	var that = this;
  	var params = {
  		method : 'wechat.wisen.out.outItems.query',
  		openId : app.globalData.userInfo.openid,
  		data : {
  			voucherId : that.data.voucherId
  		}
  	};
  	
  	netUtil.buildRequest(that,'/wisen/api/wechat/ret',params,{
  		onPre: function() {
				netUtil.showLoadingDialog(that);
			},
			onSuccess : function(resp) {
			 	
			 	netUtil.hideLoadingDialog(that);
			 
				//如果请求成功
				if(resp.ret == app.globalData.respSuccessCode) {
					
					var getOrderDetail = resp.data;
							
					getOrderDetail.getTime = util.formatOrderDetailTime(getOrderDetail.getTime);
					getOrderDetail.updateTime = util.formatOrderDetailTime(getOrderDetail.updateTime);
					getOrderDetail.endTime = util.formatOrderDetailTime(getOrderDetail.endTime);
									
					that.setData({
						getOrderDetail : getOrderDetail
					});
				
				} else {
						
						if(resp.message != undefined && resp.message != null && resp.message != '') {
 							netUtil.showAlertDialog("提示", resp.message, false, "确定", null, null);
 						} else {
 							netUtil.showAlertDialog("提示", "网络请求失败", false, "确定", null, null);
 						}
				}				
			},
			onError: function(msgCanShow, code, hiddenMsg) {
        console.log("fail");
				netUtil.hideLoadingDialog(that);
				netUtil.showAlertDialog("提示", msgCanShow, false, "确定", null, null);
			}
  		
  	}).send();
  	
  },
  
  //跳转到村查单详情修改页面
  toSaveOrderUpdatePage : function(e) {	
  		wx.navigateTo({
 				 url: '/pages/get-order-update/get-order-update?voucherId=' + this.data.voucherId
			})
  }

})